(function (aopc) {
    aopc.addExpandPage(825, function (get) {
        const Md5 = get('UtilsCommon', 'Md5');
        return {
            expandInit() {
                this.ok_dialog_view = this.getProperty('ok_dialog_view');
                this.titleProperty = this.getViewProperty(this.ok_dialog_view, 'title');
            },
            setSelfHide({ property, e }) {
                const ele = property.getElement();
                if (ele === e.target) property.setIsVisible(false);
            },
            getMeetingRoomId() {
                return { pathQuery: `?MeetingRoomId=${this.visitUser.MeetingRoomId}&MeetingId=${this.pageData.MeetingId}` };
            },
            setRowProperties({ property, rowView, p, rowData }) {
                if (p.name === 'StatusName') {
                    p.spanStyle.color = rowData.StatusName == '正常' ? '#1CCF28' : 'red';
                }
                else if (p.name === 'DeviceRole') {
                    p.valueChange = this.deviceRoleChange.bind(this);
                }
            },
            deviceRoleChange(value, selectData, property) {
                if (!property.isChanged) return;
                const { DeviceId, DisplayIndex } = property.data;
                const url = `MeetingRoomLayoutUser/SaveUserRole`;
                const IsPresident = value === '主席' ? 1 : 0;
                const entityData = { DeviceRole: value, DisplayIndex, MeetingId: this.pageData.MeetingId };

                const { serviceName, actionName } = property.serviceInterface;
                this.dispatchAction(serviceName, actionName, { url, MeetingRoomLayoutUser: entityData }).then(res => {
                    if (res && res.isSuccess !== false) {
                        this.webSocket.send('updateDeviceRole', { UserId: DeviceId, IsPresident });
                    }
                });
            },
            resetPassword({ property }) {
                this.selectDevice = property.data;
                this.titleProperty.text = property.data.DisplayIndexName + '休会密码重置';
                this.ok_dialog_view.setIsVisible(true);
            },
            successCallback() {
                this.alertSuccess('重置成功', () => this.ok_dialog_view.setIsVisible(false));
            },
            expandSetEntityData({ entityData }) {
                entityData.Password = Md5(entityData.Password);
                entityData.MeetingId = this.pageData.MeetingId;
                entityData.CreateUser = this.selectDevice.DeviceId;
                return entityData;
            }

        }
    });
})(window.aopc);